
PROCEDURE getRetAmt :

    DEFINE INPUT PARAMETER pRetType AS CHARACTER.
    DEFINE INPUT PARAMETER pSalesQty AS DECIMAL.
    DEFINE INPUT PARAMETER pSalesPrc AS DECIMAL.

    DEFINE OUTPUT PARAMETER pSalesRet AS DECIMAL.

    DEFINE VARIABLE vType AS CHARACTER.
    DEFINE VARIABLE vRate AS DECIMAL.

    pSalesRet = 0.

    IF NUM-ENTRIES(pRetType, ",") <> 2 THEN RETURN.

    vType = ENTRY(1, pRetType).
    vRate = DECIMAL(ENTRY(2, pRetType)).

    IF vType = "AMT" THEN
        pSalesRet = pSalesQty * pSalesPrc * 0.01 * vRate.
    ELSE IF vType = "QTY" THEN
        pSalesRet = pSalesQty * vRate.


END PROCEDURE.

PROCEDURE getFactor :

    DEFINE INPUT PARAMETER pProdLine AS CHARACTER.
    DEFINE INPUT PARAMETER pSite     AS CHARACTER.

    DEFINE OUTPUT PARAMETER pFactor AS DECIMAL.

    pFactor = 1.

    IF pProdLine = "110" AND NOT (pSite BEGINS "21") THEN
        pFactor = 1.06.

    IF pProdLine = "120" AND NOT (pSite BEGINS "22") THEN
        pFactor = 1.06.

    IF pProdLine = "140" AND NOT (pSite BEGINS "26") THEN
        pFactor = 1.06.

END PROCEDURE.

PROCEDURE getCost:

    DEFINE INPUT PARAMETER pSim   AS CHARACTER.
    DEFINE INPUT PARAMETER pSite  AS CHARACTER.
    DEFINE INPUT PARAMETER pPart  AS CHARACTER.
    DEFINE INPUT PARAMETER pElement AS CHARACTER.  

    DEFINE OUTPUT PARAMETER pCost AS DECIMAL.
    
    pcost = 0.

    FIND FIRST sct_det NO-LOCK WHERE sct_sim = pSim AND sct_part = pPart AND sct_site = pSite NO-ERROR.
    IF NOT AVAILABLE sct_det THEN
        FIND FIRST sct_det NO-LOCK WHERE sct_sim = "Standard" AND sct_part = pPart AND sct_site = pSite NO-ERROR.

    IF NOT AVAILABLE sct_det THEN RETURN.

    CASE CAPS(pElement):
        WHEN "ALL" THEN
            pcost = sct_cst_tot.
        WHEN "MATERIAL" THEN
            pcost = sct_mtl_tl + sct_mtl_ll.
        WHEN "LABOR" THEN
            pcost = sct_lbr_tl + sct_lbr_ll.
        WHEN "BURDEN" THEN
            pcost = sct_bdn_tl + sct_bdn_ll.
        WHEN "OVERHEAD" THEN
            pcost = sct_ovh_tl + sct_ovh_ll.
        WHEN "SUBCONTR" THEN
            pcost = sct_sub_tl + sct_sub_ll.
        OTHERWISE 
            pcost = 0.
    END CASE.

END PROCEDURE.

